package com.inga.httpclient.utils;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * Created by abing on 2015/10/23.
 */
public class HttpUtils {

    static RequestHttpService service;

    static {
        service = new RequestHttpService();
    }

    public  HttpUtils() {

    }

    /**
     * 把请求返回的HttpResponse信息 转换为 Sting的一个公共类
     * @param response
     * @return
     */
    public String httpResponseToString(HttpResponse response){
        String indexHtml = null;

        try {

            if (response!=null) {
                HttpEntity entity = response.getEntity();
                indexHtml = EntityUtils.toString(entity , "UTF-8").trim();
            }

        } catch (IOException e) {
            e.printStackTrace();
        }

        return  indexHtml;
    }



}
